%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[11pt,tikz,border=1]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{positioning}

\begin{document}
  \begin{tikzpicture}[
    neuron/.style={circle,draw,inner sep=0pt,minimum size=10mm}
    ]
    
    \begin{scope}
      \node(n) [neuron] {};
      
      \node(h0) [neuron,left=of n,yshift=1.2cm] {};
      \node(h1) [neuron,above] at (h0.north) {};
      \node(h2) [neuron,left=of n,yshift=-1.2cm] {};
      \node(h3) [neuron,below] at (h2.south) {};
      
      \node(x) [neuron,left=of h0,yshift=5mm] {$x$};
      \node(y) [neuron,left=of h2,yshift=-5mm] {$y$};
    
      \draw[->] (x) to (h0);
      \draw[->] (x) to (h1);
      \draw[->] (y) to (h2);
      \draw[->] (y) to (h3);
  
      \node (s0) at (h0.center) {$0.60$};
      \node at (s0.north) {\tiny $x$};
      \node (s1) at (h1.center) {$0.40$};
      \node at (s1.north) {\tiny $x$};
      \node (s2) at (h2.center) {$0.30$};
      \node at (s2.north) {\tiny $y$};
      \node (s3) at (h3.center) {$0.70$};
      \node at (s3.north) {\tiny $y$};
      
      \node [blue,right=5mm of h1] {$h = 0.30$};

      \draw[->] (h0) -- node [yshift=-2mm] {\scriptsize $-0.30$} (n);
      \draw[->] (h1) -- node [yshift=2mm] {\scriptsize $0.30$} (n);
      \draw[->] (h2) -- node [yshift=2mm] {\scriptsize $0.30$} (n);
      \draw[->] (h3) -- node [yshift=-2mm] {\scriptsize $-0.30$} (n);
      
      \draw[->] (n) -- ++(1cm, 0);
    \end{scope}
    
    \begin{scope}[xshift=2cm,yshift=-2.5cm]    
      % FIXME: rotate the zlabel, change plot color, and move z axis to right
      \begin{axis}[
        view={-30}{15},        
        axis background/.style={fill=blue!5},
        xlabel=$x$,
        ylabel=$y$,
        xtick distance=1,
        ytick distance=1,
        ztick distance=1,
        xtick={1},
        ytick={1},
        ztick={2},
        zmin=0,
        zmax=1,
        title=Output,
        colormap={simple}{rgb255=(235,95,95) rgb255=(255,155,145)},
        declare function={
          sigma(\z)=1/(1 + exp(-\z));
          f(\x,\y)=0.3 * (sigma(1000 * (\x - 0.4)) - sigma(1000 * (\x - 0.6))) + 0.3 * (sigma(1000 * (\y - 0.3)) - sigma(1000 * (\y - 0.7)));
          % f(x,y) = h * (sigma(1000 * (x - s1)) - sigma(1000 * (x - s2))) + h * (sigma(1000 * (y - s3)) - sigma(1000 * (y - s4)));
        }]
        \addplot3[surf,domain=0:1] {
          f(x,y)
        };
      \end{axis}
    \end{scope}
    
  \end{tikzpicture} 
\end{document}
